T1 P0
T0 P0
M291 S5 J1 F250 L190 H450 R"Set Left Tool Temperature" P"Set temperature of the filament that was last loaded in the Left Tool"
var ll = input
M291 S5 F250 L190 H450 R"Set Right Tool Temperature" P"Set temperature of the filament that was last loaded in the Right Tool"
var rr = input
G10 P0 R{var.ll} S{var.ll}
G10 P1 R{var.rr} S{var.rr}
G10 P2 R{var.ll,var.rr} S{var.ll,var.rr}
G10 P3 R{var.ll,var.rr} S{var.ll,var.rr}
if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed || !move.axes[3].homed
  G28
M116 P0 S10
M116 P1 S10
T3
M83                 ; relative extruder moves
G1 E-20 F{60}*{50}   ; retract filament
T0
G1 F18000 X-30 U30 Y-150 Z200  ; Move tools to the manual cleaning position
M291 R"Clean both Nozzles well with a metal brush" P"Click OK when ready to proceed" S3
G1 F18000 X-999 U-100 Y-150 Z200 ;move to loosen heatbreak
M291 R"Loosen the heat break on the Right tool" P"Click OK when ready to proceed" S3
G28                            ; Home the machine
G1 F18000 X0 U999 Y-30 Z5
M208 Z-2 S1
M291 S3 R"Finding Z - Offset" P"Move Z - Axis UP or DOWN with small increments to find a heigh where you start to feel the resistance of a nozzle when dragging a paper" Z1
G91
G1 Z20
G90
M291 S3 R"Remove the Paper" P"Click ""OK"" when ready"
G1 X-999 U0 Y-30
G91
G1 Z{-20 - 0.16} F600
G90
M291 S3 R"Press the Nozzle against the build plate manually (with a screwdriver) and tighten the Heat Break" P" "
G1 F18000 X-999 U-100 Y-30 Z200 ;move to tighten heatbreak
M291 R"Tighten the heat break on the Right tool" P"Click OK when ready to proceed" S3
;=========================================================================================================
;Verification
G1 F18000 X0 U999 Y-30 Z5
M291 S3 R"Finding Z - Offset" P"Move Z - Axis UP or DOWN with small increments to find a heigh where you start to feel the resistance of a nozzle when dragging a paper" Z1
G4 P260
var lt = move.axes[2].machinePosition
G91
G1 Z20
G90
G1 F18000 X-999 U0 Y-30 Z5
M291 S3 R"Finding Z - Offset" P"Move Z - Axis UP or DOWN with small increments to find a heigh where you start to feel the resistance of a nozzle when dragging a paper" Z1
G4 P260
var rt = move.axes[2].machinePosition
G90
G1 Z100 X-999 U999 Y150
M208 Z0 S1
var ddd = {var.lt} - {var.rt}
G10 P0 S0 R0
G10 P1 S0 R0
G10 P2 S0 R0
G10 P3 S0 R0
G1 F18000 X{move.axes[0].min} U{move.axes[3].max} F18000 Y150 Z100
if abs(var.ddd) <= 0.07
  M291 R{"Calibration Success, deviation is "^var.ddd^" mm"} P" " S2
else
  M291 S1 R"Calibration was not successful, Please repeat the procedure" P{"Deviation of "^var.ddd^" mm is too high."}